/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
import java.io.IOException;
import javax.microedition.lcdui.Graphics;
import javax.microedition.lcdui.Image;
import javax.microedition.lcdui.game.Sprite;
/**
 *
 * @author ANH
 */

public class TimeCount {
    private int minute;
    private int second;
    private Sprite digital;

    public TimeCount(){
       
        Reset();
    }
    public void loadGraphics(Image _image)
    {
        digital=new Sprite(_image,21,20);
        //digital.setRefPixelPosition(21,20);
    }
    public void Reset(){
        minute=0;
        second=0;
    }
    public void setTime(int m,int s){
        minute=m;
        second=s;
    }
    public void Up(){
        second++;
        if(second>59) {
            minute++;
            second=0;
        }
    }
    public void Render(Graphics g){
        int anchor = Graphics.TOP|Graphics.LEFT;

        int c,v;
        c=minute/10;
        v=minute%10;
        digital.setPosition(100, 2);
        digital.setFrame(c);
        digital.paint(g);
        digital.setPosition(114, 2);
         digital.setFrame(v);
        digital.paint(g);
        g.drawString(":", 128, 2, anchor);
        c=second/10;
        v=second%10;
        digital.setPosition(142, 2);
        digital.setFrame(c);
        digital.paint(g);
        digital.setPosition(156, 2);
         digital.setFrame(v);
        digital.paint(g);
    }
}
